package com.kongwg.java3;

import com.kongwg.java2.Employee;
import com.kongwg.java2.EmployeeData;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * @author kongwg
 * @create 2020-12-25 19:37
 */
public class StrramTest {

    /**
     * 方式一创建Stream ->list
     */
    @Test
    public void test(){
        List<Employee> employees = EmployeeData.getEmployees();
        Stream<Employee> stream = employees.stream();
        Stream<Employee> employeeStream = employees.parallelStream();


    }

    /**
     * 方式二 数组
     *
     */

    @Test
    public void test2(){
        int[] ints = {1, 2, 3, 4, 5};
        IntStream stream = Arrays.stream(ints);

        Employee e1 = new Employee(1001, "Joey");
        Employee e2 = new Employee(1002, "Reche");
        Employee[] employees = {e1, e2};
        Stream<Employee> stream1 = Arrays.stream(employees);

    }

    /**
     * three
     */
    @Test
    public void test3(){
        Stream<Integer> stream = Stream.of(1, 2, 3, 4, 5);

    }

    /**
     * wuxian
     */
    @Test
    public void test4(){
        Stream.iterate(0,i -> i+2).limit(10).forEach(System.out::println);

        System.out.println("*****************");
        Stream.generate(Math::random).limit(10).forEach(System.out::println);
    }
}
